

import java.io.*;
import java.util.*;

public class holstein
{
	static int a[]=new int[20],n,k,m,mi,pp[]=new int [20];
	List<Integer> x;
	static class PH
	{
		int v[];
		PH()
		{
			v=new int[26];
			ini();
		}
		void ini()
		{
			int i;
			for(i=0; i<25; i++)
				v[i]=0;
		}
	}
	static PH  ph[]=new PH[20],tmp=new PH(),mark=new PH();


	static void dfs(int x, int st)
	{

	int i,j,h;

	if (x==k)
	{

		tmp.ini();

		for (i=0; i<x; i++)
		{

			j=a[i];
			for (h=1; h<=m; h++)
			{
				tmp.v[h] += ph[j].v[h];
			}
		}

		boolean flag = true;
		for (i=1; i<=m; i++)
			if (tmp.v[i]< mark.v[i])
				flag=false;

		if (flag && x <mi)
		{
			mi=x;
			for (i=0; i<x; i++)
				pp[i]=a[i];
		}
		return ;
	}

	if (st>n) return ;
	for (i=st; i<=n; i++)
	{
		a[x]=i;
		dfs(x+1,i+1);
	}
}

	public static void main(String args[]) throws IOException
	{
		Scanner in = new Scanner(new FileReader("holstein.in"));
		PrintWriter out = new PrintWriter(
				new BufferedWriter( new FileWriter("holstein.out")),true);
		int i,j;
		mi=2100000000;
		
		m=in.nextInt();
		for(i=1; i<=m; i++) 
			mark.v[i]=in.nextInt();
		n=in.nextInt();
		for(i=1; i<=n; i++)
		{
			ph[i]=new PH();
			for(j=1; j<=m; j++)
				ph[i].v[j]=in.nextInt();
		}
		for(k=1;k<=n;k++)
		{
			dfs(0,1);
			if(mi <2100000000) break;
		}
		out.print(mi);
		for(i=0; i<mi; i++)
		{
			out.print(" "+pp[i]);
		}
		out.println("");
	}

	public static int[] getA()
	{
		return a;
	}

	public static void setA(int[] a)
	{
		holstein.a = a;
	}

	public static int getN()
	{
		return n;
	}

	public static void setN(int n)
	{
		holstein.n = n;
	}

	public static int getK()
	{
		return k;
	}

	public static void setK(int k)
	{
		holstein.k = k;
	}

	public static int getM()
	{
		return m;
	}

	public static void setM(int m)
	{
		holstein.m = m;
	}

	public static int getMi()
	{
		return mi;
	}

	public static void setMi(int mi)
	{
		holstein.mi = mi;
	}

	public static int[] getPp()
	{
		return pp;
	}

	public static void setPp(int[] pp)
	{
		holstein.pp = pp;
	}

	public List<Integer> getX()
	{
		return x;
	}

	public void setX(List<Integer> x)
	{
		this.x = x;
	}

	public static PH[] getPh()
	{
		return ph;
	}

	public static void setPh(PH[] ph)
	{
		holstein.ph = ph;
	}

	public static PH getTmp()
	{
		return tmp;
	}

	public static void setTmp(PH tmp)
	{
		holstein.tmp = tmp;
	}

	public static PH getMark()
	{
		return mark;
	}

	public static void setMark(PH mark)
	{
		holstein.mark = mark;
	}	
	
}